package com.jk.controller;

import com.jk.bean.GouMaiWenZhang;
import com.jk.bean.GuangGao;
import com.jk.bean.User;
import com.jk.service.GuangGaoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("guangGao")
public class GuangGaoControoller {

    @Resource
    private GuangGaoService  GuangGaoService;

    @ResponseBody
    @RequestMapping("queryGuanGao")
    public List<GuangGao>  queryGuanGao(){

        return  GuangGaoService.queryGuanGao();
    }

    @ResponseBody
    @RequestMapping("gouMaiWZ")
    public  String  gouMaiWZ(String  userid,String  tableName,String  wzid, HttpSession  session){
        Integer  jifen=GuangGaoService.gouMaiWZ(userid,tableName,wzid);
        User   us=(User)session.getAttribute("user");
          us.setJifen(jifen);

        session.setAttribute("user",us);
        return "";
    }

    @ResponseBody
    @RequestMapping("queryShiFouGouMai")
    public String queryShiFouGouMai(String  userid,String  tableName,String  wzid){
        GouMaiWenZhang  gm=GuangGaoService.queryShiFouGouMai(userid,tableName,wzid);
          if(gm == null){
              return  "1";
          }
          return  "2";
    }
}
